package com.casting;

public class DownTest {

	public static void main(String[] args) {
		Animal dog = new Dog();
		Animal cat = new Cat();
		downcasting(dog);
		downcasting(cat);
	}

	private static void downcasting(Animal animal) {

		if(animal instanceof Dog){
			DoorGod doorGod=(DoorGod)animal;
			doorGod.guard();
		}
		if(animal instanceof Cat){
			Cat cat=(Cat)animal;
			cat.speak();
		}
	}

}
